package name.zxw.vue.config;

import name.zxw.vue.interceptor.MyHandlerInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author ZhangXinWang
 * @date 2022/6/6 1:52
 */
@Configuration
public class MvcConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new MyHandlerInterceptor());
//        WebMvcConfigurer.super.addInterceptors(registry);  //这行不写也是可以的.
    }

    /*@Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                //允许所有域名进行跨域调用
                .allowedOrigins("*")
                //允许所有请求头
                .allowedHeaders("*")
                //允许所有方法
                .allowedMethods("*")
                //表示探测请求的有效期
                .maxAge(3600);
//        WebMvcConfigurer.super.addCorsMappings(registry);  //这行不写也是可以的.
    }*/
}
